package com;

import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOServer;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author Ricky
 * @date 2020-8-26
 */
@Component
public class SocketIOConfig {

    @Setter
    @Value("${socketio.port}")
    private Integer port;

    /**
     * 以下配置在上面的application.properties中已经注明
     *
     * @return SocketIOServer实例
     */
    @Bean
    public SocketIOServer socketIOServer() {
        Configuration config = new Configuration();
        config.setPort(port);
        config.setRandomSession(true);
        return new SocketIOServer(config);
    }
}
